package io.github.frailty9.crserver.model

import java.time.LocalDateTime
import java.time.LocalDate
import com.mybatisflex.annotation.Column
import com.mybatisflex.annotation.Id

/**
 * 资源主表
 */
data class Resource(
    @Id
    override var id: Long? = null,
    /**
     * 资源名称，如：东区篮球场A
     */
    var name: String? = null,
    /**
     * 描述
     */
    var description: String?? = null,
    /**
     * 资源样图URL
     */
    var imageUrl: String?? = null,
    /**
     * 创建者 account.id
     */
    var creatorId: Long? = null,
    /**
     * 用户在每个周期内可预约的最大数量
     */
    var maxBookingsPerCycle: Int? = null,
    /**
     * 每个物理实体包含的单位数（如：2单位=1全篮球场）
     */
    var unitPerPhysical: Int? = null,
    /**
     * 单位名称，如“半场”、“台”
     */
    var unitName: String? = null,
    /**
     * 可见学院，如 CS,EE
     */
    var visibleToColleges: String?? = null,
    /**
     * 可见专业，如 英语,数学
     */
    var visibleToMajors: String?? = null,
    /**
     * 年级，如 2022,2023
     */
    var visibleToGrades: String?? = null,
    /**
     * 可见班级，如 A2501,B2502
     */
    var visibleToClasses: String?? = null,
    /**
     * 重复类型: ONCE, DAILY, WEEKLY, MONTHLY
     */
    var repeatType: String? = null,
    /**
     * 开放模式: FIXED_TIME（统一时间开放）, PER_INSTANCE（每个实例独立开放）
     */
    var bookingOpenMode: String? = null,
    /**
     * Instance开始前多久可预约（秒）默认3天
     */
    var bookingOpenBeforeSeconds: Int? = null,
    /**
     * 资源进行中是否可预约
     */
    var allowBookingOnUsage: Int? = null,
    /**
     * 计划生效开始日期
     */
    var effectiveStart: LocalDate? = null,
    /**
     * 计划生效结束日期
     */
    var effectiveEnd: LocalDate? = null,
    /**
     * 0=下架, 1=上架
     */
    var status: Int? = null,

    @Column(version = true)
    override var version: Int? = null,

    @Column(onInsertValue = "CURRENT_TIMESTAMP")
    var createTime: LocalDateTime? = null,

    @Column(onInsertValue = "CURRENT_TIMESTAMP", onUpdateValue = "CURRENT_TIMESTAMP")
    var updateTime: LocalDateTime? = null,

    @Column(isLogicDelete = true)
    override var deleted: Int? = null
) : BaseModel
